- /* scftanbs.cpp by K.Tsuru */
- // function ID = 9123 since ver.2.18
- /*****************************************
- SComplex class
- It returns tan(z) using binary splitting method.
- Let z = x+iy,
- tan(z) = {sin(2*x)+i*sinh(2*y)}/{cos(2*x)+cosh(2*y)}.
- *****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SComplex CtanBS(const SComplex& z){
- SDouble c2, s2, ch2, sh2;
- CosSinBS(2 * z.Real(), c2, s2); // c2 = cos(2x), s2 = sin(2x)
- SDouble e, r;
- int ys = z.Imag().Sign(9122);
-
- if(ys > 0) { // y > 0
- e = ExpBS(2 * z.Imag()); // = exp(2y)
- r = 1/e;
- ch2 = DDiv2(e + r); // = cosh(2y)
- sh2 = ch2 - r; // = sinh(2y)
- } else if(ys == 0) { // y = 0
- ch2 = 1; sh2 = 0.0;
- } else { // y < 0
- e = ExpBS(-2 * z.Imag()); // = exp(-2y)
- r = 1/e;
- ch2 = DDiv2(e + r); // = cosh(-2y)
- sh2 = ch2 - e; // = -sinh(-2y)
- }
-
- SDouble r_den, rr, ri;
- r_den = 1.0/(c2 + ch2);
-
- rr = s2 * r_den;
- ri = sh2 * r_den;
-
- return SComplex(rr, ri);
- }
scftanbs.cpp : last modifiled at 2008/12/08 16:37:56(999 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).